import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:window_example/page_navigation/catalogue_item.dart';
import 'package:window_example/page_navigation/page_navigation_cubit.dart';
import 'package:window_example/util/print_util.dart';

import '../constant/constant.dart';

class CataloguePage extends StatelessWidget {
  List<Color> backgroundColors = [Colors.cyan, Colors.cyan];
  var itemList = <CatalogueItemWidget>[];

  CataloguePage({super.key});

  @override
  Widget build(BuildContext context) {
    // print("${...itemList}");
    var itemList = <CatalogueItemWidget>[
      CatalogueItemWidget(() {
        context.read<PageNavigationCubit>().toWebViewPage();
      }, "WebViewPage"),
      CatalogueItemWidget(() {
        context.read<PageNavigationCubit>().toBanner();
      }, "Banner"),
      // CatalogueItemWidget(() {
      //   context.read<PageNavigationCubit>().toDrawer();
      // }, "Drawer"),
      CatalogueItemWidget(() {
        context.read<PageNavigationCubit>().toTab();
      }, "Tab bar"),
      CatalogueItemWidget(() {
        context.read<PageNavigationCubit>().toDataList();
      }, "Data List(网络数据获取、json解析、上拉加载、下拉刷新)"),
    ];
    return Container(
      width: catalogueWidth,
      margin: EdgeInsets.all(catalogueMargin),
      decoration: BoxDecoration(
          gradient: LinearGradient(colors: [
            Colors.cyan.withOpacity(0.8),
            Colors.cyan.withOpacity(0.6)
          ]),
          borderRadius: const BorderRadius.all(Radius.circular(6))),
      child: Column(
        mainAxisSize: MainAxisSize.max,
        children: [...itemList],
      ),
    );
  }
}
